package by.gusto.afisha.fragments;

import java.util.ArrayList;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import br.com.dina.ui.widget.UITableView;
import by.gusto.afisha.R;
import by.gusto.afisha.model.Place;

import com.actionbarsherlock.app.SherlockFragment;

public class PlaceListFragment extends SherlockFragment {
	public static final String CATEGORY_ID = "Category.id";
	private UITableView mTableView;
	
	@Override
	public final View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
		View v = inflater.inflate(R.layout.place_list, null);
		mTableView = (UITableView) v.findViewById(R.id.table);
		Bundle args = getArguments();
		ArrayList<Place> places = Place.getPlacesByParentId(args.getInt(CATEGORY_ID, 0));
		
		for (Place place : places) {
			mTableView.addBasicItem(place.name, String.valueOf(place.categoryId));
		}
		mTableView.commit();
		return v;
	}
}
